<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 在app模板里面寻找 -->
      <!-- 根据app.isShow来显示 -->
      <cpn v-show="isShow"></cpn>
    </div>

    <template id="cpn">
      <div>
        <h2>我是子组件</h2>
        <p>我是内容,hhhh</p>
        <!-- 在组件的作用域中查找 -->
        <button v-show="isShow"></button>
      </div>
    </template>

    <script src="../js/vue.js"></script>

    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "你好",
          isShow: true,
        },
        components: {
          cpn: {
            template: "#cpn",
            data() {
              return {
                isShow: false,
              };
            },
          },
        },
      });
    </script>
  </body>
</html>
